package entities;
// default package
// Generated 2014-07-29 18:57:10 by Hibernate Tools 3.4.0.CR1

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;

@Entity
@Table(name="T_INVOICE")
public class Invoice implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	private int invoiceId;
	private String invoiceNumber;
	private Customer customer;
	private RetailOrder retailOrder;
	private String paymentMethod;
	private Date paymentDeadline;
	private String isPaid;
	private Date salesDate;
	private Set<InvoiceDetails> invoiceDetails = new HashSet<>(0);

	public Invoice() {
	}

	public Invoice(String invoiceNumber, Customer customer, RetailOrder retailOrder,
			String paymentMethod, Date paymentDeadline, String isPaid, Date salesDate) {
		this.invoiceNumber = invoiceNumber;
		this.customer = customer;
		this.retailOrder = retailOrder;
		this.paymentMethod = paymentMethod;
		this.paymentDeadline = paymentDeadline;
		this.isPaid = isPaid;
		this.salesDate = salesDate;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name="INVOICE_ID",unique = true, nullable = false)
	public int getInvoiceId() {
		return invoiceId;
	}

	public void setInvoiceId(int invoiceId) {
		this.invoiceId = invoiceId;
	}

	@Column(name="INVOICE_NUMBER", nullable=false)
	public String getInvoiceNumber() {
		return invoiceNumber;
	}

	public void setInvoiceNumber(String invoiceNumber) {
		this.invoiceNumber = invoiceNumber;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "INVOICE_CUSTOMER_ID", nullable = false)
	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "RETAIL_ORDER_ID", nullable = false)
	public RetailOrder getRetailOrder() {
		return retailOrder;
	}

	public void setRetailOrder(RetailOrder retailOrder) {
		this.retailOrder = retailOrder;
	}

	@Column(name="PAYMENT_METHOD", nullable=false)
	public String getPaymentMethod() {
		return paymentMethod;
	}

	public void setPaymentMethod(String paymentMethod) {
		this.paymentMethod = paymentMethod;
	}

	@Column(name="PAYMENT_DEADLINE", nullable=false)
        @Temporal(javax.persistence.TemporalType.DATE)
	public Date getPaymentDeadline() {
		return paymentDeadline;
	}

	public void setPaymentDeadline(Date paymentDeadline) {
		this.paymentDeadline = paymentDeadline;
	}

	@Column(name="IS_PAID", nullable=false)
	public String getIsPaid() {
		return isPaid;
	}

	public void setIsPaid(String isPaid) {
		this.isPaid = isPaid;
	}

	@Column(name="SALES_DATE", nullable=false)
        @Temporal(javax.persistence.TemporalType.DATE)
	public Date getSalesDate() {
		return salesDate;
	}

	public void setSalesDate(Date salesDate) {
		this.salesDate = salesDate;
	}

	@OneToMany(fetch = FetchType.EAGER, mappedBy = "invoice", cascade = CascadeType.ALL)
	public Set<InvoiceDetails> getInvoiceDetails() {
		return invoiceDetails;
	}

	public void setInvoiceDetails(Set<InvoiceDetails> invoiceDetails) {
		this.invoiceDetails = invoiceDetails;
	}


	
}
